import type { R } from './model/resultModel';
import type { RouterVo } from './model/routeModel';
import type { UserInfo, LoginParam, LoginVo } from './model/loginModel';
import { request } from '@/utils/request';

/**
 * 获取路由菜单
 */
export const getRouters = () => {
  console.log('[API] 调用 getRouters 接口');
  return request.get<R<Array<RouterVo>>>({
    url: '/system/menu/getRouters',
  });
};

/**
 * 获取用户路由菜单（别名，保持兼容性）
 */
export const getUserRouters = () => {
  return request.get<R<Array<RouterVo>>>({
    url: '/system/menu/getRouters',
  });
};

/**
 * 获取用户信息
 */
export const getUserInfo = () => {
  return request.get<R<UserInfo>>({
    url: '/system/user/getInfo',
  });
};

/**
 * 登录
 */
export const login = (data: LoginParam) => {
  return request.post<R<LoginVo>>({
    url: '/auth/login',
    data,
  });
};

/**
 * 退出登录
 */
export const logout = () => {
  return request.post<R<void>>({
    url: '/auth/logout',
  });
};
